package edu.xhu;

import android.content.Context;
import android.widget.Toast;

import com.net.ClientError;

/**
 * 错误提示
 * @author swerit
 *
 */

public class ErrorShow {

	public static void showError(Context context, ClientError ed){
		switch (ed.getCode()) {
		case ClientError.ERROR_CONNECTION:
			if ("错误消息：200".equals(ed.getMessage())){
				Toast.makeText(context, "请确认是否进行了教学质量评价！", Toast.LENGTH_SHORT).show();
			}else {
				//网络连接错误
				Toast.makeText(context, R.string.network_error, Toast.LENGTH_SHORT).show();
			}
			
			break;
			
		case ClientError.ERROR_PRASE_HTML:
			//未知错误
			Toast.makeText(context, R.string.parse_error, Toast.LENGTH_SHORT).show();
			break;
			
		case ClientError.ERROR_INTERVAL:
			//参数传递错误，指的是loadData(...)时的参数;
			Toast.makeText(context, R.string.paramenter_error, Toast.LENGTH_SHORT).show();
			break;
			
		case ClientError.ERROR_PASSWD:
			//密码或用户名错误
			Toast.makeText(context, R.string.account_error, Toast.LENGTH_SHORT).show();
			break;
			
		case ClientError.ERROR_NETWORK:
			//未打开网络开关
			Toast.makeText(context, R.string.not_open_netswitch, Toast.LENGTH_SHORT).show();
			break;
			
		case ClientError.ERROR_TIMEOUT:
			//网络请求超时
			Toast.makeText(context, R.string.net_outof_time, Toast.LENGTH_SHORT).show();
			break;
			
		default:
			//其它错误
			Toast.makeText(context, "网页数据有变动，解析异常，请等待我们的维护！", Toast.LENGTH_SHORT).show();
			
			break;
		}
	}
}
